<%--
 *  @Author: Kevinfan
 *  Date:    2010/3/2
 *
 *  Copyright (C) 2000 - 2012 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>

<%
  //init param
  Category cat = Category.getInstance("jsp.PurchaseChannel");
  String strModuleName = "ERM";
  String contextPath = request.getContextPath();
%>
<% //--------------------  include files list --%>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<%int LangNums = ConstantProp.multiLangNumber;%>
<html>
<head>
<title>PurchaseChannel</title>
<PageFlow:CheckPageFlow pageName="p_zylproductgrouppop"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/Calendar.js"></script>
<script language="JavaScript">

function checkALLElems(obj)
{
  var t = null;
  var currentObj = obj;
  if(obj==null)
    currentObj = document;
  if(top.topFrame != null)
    t = top.topFrame;
  if(t == null && opener != null && opener.top != null && opener.top.topFrame != null)
    t = opener.top.topFrame;
  if(t == null && opener != null && opener.opener != null && opener.opener.top != null && opener.opener.top.topFrame != null)
    t = opener.opener.top.topFrame;
  if(t != null)
    message = t.message;
  else
    message = new ActiveXObject("Scripting.Dictionary");
  for(var i=0;i<currentObj.all.length;i++)
  {
    var elem = currentObj.all[i];
    if(!checkType(elem))
      return false;
    if(!checkCommand(elem))
      return false;
    if(!checkLength(elem))
      return false;
    if(!checkMaxValue(elem))
      return false;
  }
  return true;
}

function checkCommand(elem)
{
  message = top.message;
  if(elem.command == null)
    return true;
  var arr = elem.command.split(",");
  for(var i=0;i < arr.length;i++)
  {
    if(  (arr[i] == "notnull" && isEmpty(elem.value))
      || (arr[i] == "notnull" && elem.type == "select-one" && elem.value == "-1"))
    {
      if(elem.label == null)
        alert(elem.name+" can not be null!");
      else
        alert(replaceString("<%= message.getMessageDesc("VALUE_NOT_NULL") %>","%s",elem.label.replace("\'","'")));
      if(elem.type!='hidden')
      	elem.focus();
      return false;
    }
  }
  return true;
}
function page_add()
{
  if(!checkALLElems(document.cform))return;
  cform.actionname.value = "add";
  cform.target = "_self";
  isRunning = true;
  document.cform.submit();
}

function page_delete()
{
  if(isNullChecked(cform.deleteids)) 
  {
    alert('<%=message.getMessageDesc("PLEASE_SELECT")%>');
    return;
  }
  if(!confirm('<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>'))
     return;
  cform.actionname.value = "delete";
  cform.target = "_self";
  isRunning = true;
  document.cform.submit();
}

function page_setOrg4(id,name,code)
{
  document.cform.purchasechannelid.value = id;
  document.cform.purchasechannelcode.value = code;  
  document.cform.purchasechannelname.value = name;
  var remote = window.open("","newwindow");
  if (remote != null)
    remote.close();
}

function page_allcheckselect(){
	var allcheck = cform.allcheck.checked;
	var alldatafile = document.getElementsByName('deleteids');
	var length = alldatafile.length;
	if(allcheck){
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = true;
		}
	}else{
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = false;
		}	
	}
}
</script>
</head>
<%
String strDisplayFlag="";
if(request.getParameter("displayflag")!=null)
{
  strDisplayFlag=request.getParameter("displayflag");
}
%>
<iframe name="reloadHandler" style="display:none" ></iframe>
<body>
<table width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td class="summary_top"></td>
  </tr>
</table>
<table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0">
  <form id="pageform" name="cform" method="post" action="/oval/Dispatcher" >
  <input type="hidden" name="pagename" value="p_zylproductgrouppop">
  <input type="hidden" name="actionname">
  <custom:hidden property="doctorid"/>
  <custom:hidden property="userid" name="userinfo" scope="session"/>
  <custom:hidden property="hpid"/>
		<tr class="deepblue-left"> 
		  	<%if(!(strDisplayFlag).equals("view")){%>
		  	<td width="4%" class="title_center"><input type="checkbox" name="allcheck" class="normalradio" onclick="page_allcheckselect();"></td>
          	<%} %>
          	<td  class="title_center"><%= label.getLabelName("L_ProductGroup") %></td>
	  	</tr>
      	  <%
            Vector summary = (Vector)pageContext.getAttribute("totalsummary");
            if(summary == null)
              summary = new Vector();
            int i=1;
            int org =0;;
            String strClassType="none";
          %>
          <logic:iterate id="info" collection="<%= summary %>" >
          <%
            if(i%2==0)
              strClassType="td-listrom";
            else
              strClassType="none";
            i++;
          %>
         <tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull(strClassType)%>'"  class="<%=JspHelper.filterNull(strClassType)%>"> 
            <%if(!(strDisplayFlag).equals("view")){%>
            <td class="title_center"> 
              	<input type="checkbox" name="deleteids" id="deleteids<%=JspHelper.filterNull(i-1)%>" value="<custom:write name="info" property="doctorproductgroupid"/>" class="normalradio" />
            </td>
            <%} %>
            <td class="td_center"><custom:write name="info" property="productgroupname" nbsp="true"/></td>
          </tr>
          </logic:iterate>
          <input type="hidden" name="nums" value="<%=JspHelper.filterNull(summary.size())%>">
          <input type="hidden" name="numrows" value="<%=LangNums*(JspHelper.filterNull(summary.size())+1)%>">
          <%if(!(strDisplayFlag).equals("view")){%>
          <span id="newdetail">
          <tr class="none"> 
          	<td>&nbsp;</td>
            <td class="td_center">
            	<custom:select optionInnerTextKey="productgroupname" name="doctorinfo" optionsName="allpgroups" property="productgroupid" optionValueKey="productgroupid" label="L_ProductGroup" command="notnull" defaultValue="----------------------"/>
            </td>
          </tr>
          </span>
          <%} %>
  </form>
</table>
	<%if(!(strDisplayFlag).equals("view")){%>
	<table width="100%" cellspacing="0" cellpadding="0">
		<tr>
			<td class="summary_top"></td>
		</tr>
		<tr>
			<td class="td_center">
			<a onclick="javascript:page_add();"><custom:button type="2" label="L_Add" imgsrc="add.gif" border="0" style="width:60"/></a>
			<a onclick="javascript:page_delete();"><custom:button type="2" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60"/></a>	
			</td>	
		</tr>
	</table>
	<%} %>
</body>
</html>